package com.landary.parameterrplacement.service;

import com.landary.parameterrplacement.entity.AvicOrg;
import com.landary.parameterrplacement.utils.XmlToMapUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author 刘欣
 * @createTime 2023/8/1 8:55
 * @description 获取虚拟组织
 */
@Service
public class AnalysisAvicOrgXmlService {

    public List<AvicOrg> xmlToMap(String xml, String tagName) throws Exception {
        List<Map<String, String>> listMap = (List<Map<String, String>>) XmlToMapUtils.xmlToMap(xml, tagName);
        List<AvicOrg> avicOrgs = AvicOrg.mapToUserList(listMap);
        if (avicOrgs == null || avicOrgs.size() == 0) {
            throw new Exception("xml解析有误！");
        }
        return avicOrgs;
    }
}
